<?php
// 办事指南
namespace app\home\controller;
use think\Db;
class Zhinan extends HomeBase {

	public function getlist() {
		$order = input('order');	// 排序
		$page = input('page','1','intval');		// 当前页
		$row = input('row','10','intval');		// 每页显示数据

		// 排序
		if (empty($order)) $order = 'create_time desc';
		
		// 分页
		$start = ($page-1) * $row;

		$total = Db::name('Zhinan')->count('id');
		$list = Db::name('Zhinan')->order($order)->limit($start,$row)->field('id,title,keshi,create_time,update_time')->select();

		if (empty($list)) 
			return json(array('status'=>0,'msg'=>'暂无数据'));
		else {
			return json(array('status'=>1,'info'=>$list,'count'=>$total));
		}
	}

	public function getdetail() {
		$znid = input('znid');
		$znid = intval($znid);
		$info = Db::name('Zhinan')->where('id',$znid)->find();
		if (!$info)
			return json(array('status'=>0,'msg'=>'数据未找到'));
		return json(array('status'=>1,'info'=>$info));
	}
}